<template>
  <!-- 左边 -->
  <div class="center">
    <div class="left">
      <ul >
        <!-- <router-link >{{$store.state.list2[2].name}}</router-link> -->
        <!-- <li  class="leimu"  v-for="item in $store.state.list2" :key="item.type"> -->
        <!-- <li class="leimu"><router-link to="/home/goods">{{item.name}}</router-link></li> -->
        <li
          class="leimu"
          v-for="(item, index) in $store.state.goods"
          :key="item.type"
        >
          <a :href="`#${index}`">{{ item.name }}</a>
        </li>
      </ul>
    </div>
  </div>
  <!-- 右边 -->
  <ol class="list">
    <li v-for="(item, index) in $store.state.goods" :key="item.name">
      <h3 :id="index">{{ item.name }}</h3>
      <ul class="info">
        <li v-for="item2 in item.foods" :key="item2.name">
          <div class="box1">
            <div class="pic">
              <img :src="item2.image" alt="" />
            </div>
            <div class="title">
              <h4>{{ item2.name }}</h4>
              <span>￥{{ item2.price }}</span>
            </div>
            <btn :item="item2" type="0"> </btn>
          </div>
        </li>
      </ul>
    </li>
  </ol>

  <footer @click="changeIsShow">
    <button  class="shopCar">
      <img class="carImg" src="src\img\cart.png" alt="" />
    </button>
    <span class="money"> ￥{{ $store.state.price }}</span>
    <span>另需配送￥4 元 </span>
    <div class="right">{{ $store.state.str1 }}</div>
  </footer>
  <div class="dianCar" v-show="isShow">
    <div class="top" @click="changeIsShow"></div>
    <div class="bottom">
      <p class="cartile">购物车 <span @click="clear">清空</span></p>
      <ul>
        <li
          class="carlist"
          v-for="item in $store.state.carList"
          :key="item.name"
          v-show="item.count"
        >
          <span>{{ item.name }}</span>
          <div class="carbutn1">
            <Btn :item="item"></Btn>

          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Btn from './btn.vue';
export default {
  data() {
    return {
      isShow: false,
    };
  },
  beforeCreate() {
    // console.log(this.$store.state.goods)
  },
  methods: {
    changeIsShow() {
      this.isShow = !this.isShow;
  
    },
    clear(){
      this.$store.commit('clear');
    },
   
  },
  components: {
    Btn,
  },
};
</script>

<style scoped>
.carbutn1>span{
margin:0 20px 0 20px
}
.carImg {
  float: left;
  clear: both;
}
.cartile {
  display: flex;
  justify-content: space-between;
}
.cartile > span {
  margin: 0 60px 0 60px;
}
.carBtn {
  border: 3px solid rgb(0, 160, 220);
  border-radius: 50%;
  display: block;
  height: 1.5rem;
  width: 1.5rem;
  line-height: 1.5rem;
  text-align: center;
  margin: 0 10px 0 10px;
  color: rgb(0, 160, 220);
}

.carlist > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 190px;
  line-height: 1;
}
 .center>.list ul{

 }

.carlist {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dianCar {
  /* background: rgba(33, 31, 31, 0.347);
   */
   background: rgba(7, 17, 27, 0.6);
  height: calc(100% - 4rem);
  width: 100%;
  position: fixed;
  /* top: 0; */
  bottom: 4rem;
}

.dianCar li {
  background-color: white;
  font-size: 1rem;
  height: 2.5rem;
  line-height: 2.5rem;
  padding-left: 2rem;
}

.dianCar p {
  height: 2.5rem;
  background-color: bisque;
  line-height: 2.5rem;
  padding-left: 2rem;
}

.dianCar > .bottom {
  position: absolute;
  bottom: 0;
  width: 100%;
}

footer {
  position: fixed;
  bottom: 0;
  height: 4rem;
  background: #141d27;
  display: flex;
  align-items: center;
  width: 100%;
  color: rgb(255, 255, 255, 0.4);
}

footer > .shopCar {
  border-radius: 50%;
  height: 3.5rem;
  width: 3.5rem;
  margin-top: -1rem;
  margin-left: 1.25rem;
  background: rgb(255, 255, 255, 0.4);
}

.shopCar > img {
  width: 120%;
  margin-top: -9px;
  margin-left: -3px;
}

footer > .money {
  margin-left: 0.5rem;
  margin-right: 1.25rem;
}

footer > .right {
  position: absolute;
  right: 0;
  width: 6.25rem;
  background: rgb(255, 255, 255, 0.4);
  height: 100%;
  text-align: center;
  line-height: 2rem;
}

.h2 {
  height: 1.7rem;
  text-align: start;
  color: gray;
  background: #f3f5f7;
  border-left: 3px black solid;
  padding-left: 1.4rem;
  border-bottom: 2px solid;
  border-bottom: 0.125rem solid rgb(7, 17, 27, 0.1);
}

.titlee {
  font-size: 0.9rem;
  margin-bottom: 0.0187rem;
}

.price {
  color: red;
}

.shuliang {
  margin-left: 0.5rem;
}

.jia {
  margin-left: 0.625rem;
}

.box > ul > li {
  height: 6rem;
  display: flex;
  justify-content: space-between;
  border-bottom: 0.125rem solid rgb(7, 17, 27, 0.1);
  background-color: aliceblue;
  float: left;
}

.imgg {
  height: 5rem;
  width: 35%;
}

.imgg > img {
  height: 100%;
  /* width: 100%; */
  padding-left: 1rem;
  padding-top: 1rem;
  box-sizing: border-box;
}

.right {
  flex: 1;
  display: flex;
  justify-content: space-between;
  padding-left: 1rem;
  padding-top: 1rem;
  box-sizing: border-box;
  font-size: 0.8rem;
}

.num {
  width: 60%;
  margin-top: 3.1rem;
  margin-right: 0.3rem;
}

.num > button {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: skyblue;
  color: white;
  font-size: 1.2rem;
  border: 0;
}

.wenzi {
  flex: 1;
}

.center {
  overflow: auto;
  float: left;
 


}

.center > .left ul {
  overflow-y: scroll;
  height: 500px;
}

.leimu {
  height: 4.25rem;
  display: block;
  /* line-height: 6.25rem; */
  font-size: 1rem;
  color: rgb(0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f5f7;
}

.leimu > a {
  color: rgba(0, 0, 0, 0.582);
  text-decoration: none;
  text-align: center;
  /* color: ; */
}

.center {
  display: flex;
  height: 800px;
}

.center > .left {
  width: 6rem;
  /* background: yellow; */
}

.center > .right {
  flex: 1;
  /* background: skyblue; */
}

.list {
  flex: 1 1 auto;
  overflow-y: scroll;
  height: 800px;
}

.list h3 {
  border-left: 4px #d9dde1 solid;
  background: #f3f5f7;
  height: 26px;
  line-height: 26px;
  padding-left: 12px;
  color: rgb(147, 153, 159);
  font-weight: 400;
  font-size: 12px;
}

.list > ul {
  overflow-y: scroll;
  height: 100%;
}

.list .info li {
  padding: 0 18px;
  position: relative;
}

.list .box1 {
  display: flex;
  padding: 18px 0;
  border-bottom: 1px rgba(1, 17, 27, 0.1) solid;
}

.list .pic img {
  width: 100px;
}

.title {
  padding-left: 10px;
}
</style>
